#include <stdio.h>
#include <math.h>


int main() {

// simple defines
#define FNORD hello
int FNORD = 23;
printf("num is %d\n", hello);

#define NOBODY_HOME
static NOBODY_HOME int thing = 42;
printf("thing is %d\n", thing);

// active macro without macro hygiene
#define SUM(x, y) x + y
int v = SUM(23, 42);
printf("s = %d\n", v);

// conditional compilation (if compiled with flag -D<MACRO>=<VALUE>
#if (THING != 0)
  printf("thing %d\n", THING);
#endif

#ifdef THING
  printf("thing is defined\n");
#endif

#define FIVE 5
#define PRINT(x) printf("%s = %d\n", #x, x)

PRINT(FIVE);
PRINT(5);
PRINT(5*10);
PRINT((int)sqrt(FIVE*FIVE) + (int)log(25/5));

int z = 100, dz = 256;
PRINT(z+dz);

#define GUM(a, b) a##b
GUM(print, f) ("test line\n");

PRINT(__APPLE_CC__);
printf("%s file:%s; in function:%s; line:%d\n", __DATE__, __FILE__, __func__, __LINE__); 
printf("__FUNCTION__=%s; __func__=%s; __PRETTY_FUNCTION__=%s\n", __FUNCTION__, __func__, __PRETTY_FUNCTION__);

return 0;
}
